import { S } from '../../s';
import { IPSEditor } from '../ipseditor';
import { IPSSysPanelField } from './ipssys-panel-field';
import { PSSysPanelItemImpl } from './pssys-panel-item-impl';
import { IPSSysCss } from '../../res/ipssys-css';
import { IPSSysImage } from '../../res/ipssys-image';

export class PSSysPanelFieldImpl
  extends PSSysPanelItemImpl
  implements IPSSysPanelField
{
  get fieldStates(): 1 | 2 {
    return this.M.fieldStates != null ? this.M.fieldStates : 0;
  }

  get labelCssStyle(): string {
    return this.M.labelCssStyle;
  }

  get labelDynaClass(): string {
    return this.M.labelDynaClass;
  }

  protected labelpssyscss: IPSSysCss;
  getLabelPSSysCss(): IPSSysCss | null {
    return (
      this.labelpssyscss ||
      (this.labelpssyscss = this.fillObjectModel(
        S._278,
        this.M.getLabelPSSysCss,
        S._2e7,
      ) as IPSSysCss)
    );
  }

  get outputCodeListConfigMode(): 0 | 1 | 2 {
    return this.M.outputCodeListConfigMode != null
      ? this.M.outputCodeListConfigMode
      : 0;
  }

  protected pseditor: IPSEditor;
  getPSEditor(): IPSEditor | null {
    return (
      this.pseditor ||
      (this.pseditor = this.fillObjectModel(
        S._12e,
        this.M.getPSEditor,
        S._2f0,
      ) as IPSEditor)
    );
  }

  protected pssysimage: IPSSysImage;
  getPSSysImage(): IPSSysImage | null {
    return (
      this.pssysimage ||
      (this.pssysimage = this.fillObjectModel(
        S._27b,
        this.M.getPSSysImage,
        S._2ad,
      ) as IPSSysImage)
    );
  }

  get valueFormat(): string {
    return this.M.valueFormat;
  }

  get valueItemName(): string {
    return this.M.valueItemName;
  }

  get viewFieldName(): string {
    return this.M.viewFieldName;
  }

  get allowEmpty(): boolean {
    return this.M.allowEmpty != null ? this.M.allowEmpty : true;
  }

  get convertToCodeItemText(): boolean {
    return this.M.convertToCodeItemText != null
      ? this.M.convertToCodeItemText
      : false;
  }

  get hidden(): boolean {
    return this.M.hidden;
  }

  get needCodeListConfig(): boolean {
    return this.M.needCodeListConfig != null
      ? this.M.needCodeListConfig
      : false;
  }

  get showCaption(): boolean {
    return this.M.showCaption;
  }
  get cls(): string {
    return 'PSSysPanelFieldImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._186 || cls == S._187) return true;
    return super.instanceof(cls);
  }
}
